package com.qf.service.impl;

import com.qf.Excaption.MyExcaption;
import com.qf.domain.NewsComment;
import com.qf.mapper.NewsCommentMapper;
import com.qf.mapper.NewsDetailMapper;
import com.qf.service.NewsCommentService;
import com.qf.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NewsCommentServiceimpl implements NewsCommentService {
    @Autowired
    private NewsCommentMapper newsCommentMapper;
    @Override
    public ResultVO selectcomment(Integer newid) {
        ResultVO resultVO=new ResultVO();
        if (newid!=null){
            List<NewsComment> list =newsCommentMapper.selectcomment(newid);
            resultVO.setData(list);
            return resultVO;
        }else {
            resultVO.setMsg("没有收到newid数据");
            resultVO.setCode(500);
            return resultVO;
        }

    }

    @Override
    public int insertadd(NewsComment newsComment) {
        if (newsComment==null){
            throw  new MyExcaption("数据异常",500);
        }
        int i=newsCommentMapper.insertadd(newsComment);
        if (i!=1){
            throw  new MyExcaption("错",500);
        }else {
            return 1;

        }
    }

    @Override
    public int deletenews(Integer newsid) {
        if (newsid==null){
            throw new MyExcaption("无参",500);
        }
        int deletecomment = newsCommentMapper.deletecomment(newsid);
        return deletecomment;
    }
}
